/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class AvailabilityAttributes
    {
    
        private String availabilityTypeField;

        private Boolean? isPreorderField;

        private Decimal? minimumHoursField;

        private Decimal? maximumHoursField;


        /// <summary>
        /// Gets and sets the AvailabilityType property.
        /// </summary>
        [XmlElementAttribute(ElementName = "AvailabilityType")]
        public String AvailabilityType
        {
            get { return this.availabilityTypeField ; }
            set { this.availabilityTypeField= value; }
        }



        /// <summary>
        /// Sets the AvailabilityType property
        /// </summary>
        /// <param name="availabilityType">AvailabilityType property</param>
        /// <returns>this instance</returns>
        public AvailabilityAttributes WithAvailabilityType(String availabilityType)
        {
            this.availabilityTypeField = availabilityType;
            return this;
        }



        /// <summary>
        /// Checks if AvailabilityType property is set
        /// </summary>
        /// <returns>true if AvailabilityType property is set</returns>
        public Boolean IsSetAvailabilityType()
        {
            return  this.availabilityTypeField != null;

        }


        /// <summary>
        /// Gets and sets the IsPreorder property.
        /// </summary>
        [XmlElementAttribute(ElementName = "IsPreorder")]
        public Boolean IsPreorder
        {
            get { return this.isPreorderField.GetValueOrDefault() ; }
            set { this.isPreorderField= value; }
        }



        /// <summary>
        /// Sets the IsPreorder property
        /// </summary>
        /// <param name="isPreorder">IsPreorder property</param>
        /// <returns>this instance</returns>
        public AvailabilityAttributes WithIsPreorder(Boolean isPreorder)
        {
            this.isPreorderField = isPreorder;
            return this;
        }



        /// <summary>
        /// Checks if IsPreorder property is set
        /// </summary>
        /// <returns>true if IsPreorder property is set</returns>
        public Boolean IsSetIsPreorder()
        {
            return  this.isPreorderField != null;

        }


        /// <summary>
        /// Gets and sets the MinimumHours property.
        /// </summary>
        [XmlElementAttribute(ElementName = "MinimumHours")]
        public Decimal MinimumHours
        {
            get { return this.minimumHoursField.GetValueOrDefault() ; }
            set { this.minimumHoursField= value; }
        }



        /// <summary>
        /// Sets the MinimumHours property
        /// </summary>
        /// <param name="minimumHours">MinimumHours property</param>
        /// <returns>this instance</returns>
        public AvailabilityAttributes WithMinimumHours(Decimal minimumHours)
        {
            this.minimumHoursField = minimumHours;
            return this;
        }



        /// <summary>
        /// Checks if MinimumHours property is set
        /// </summary>
        /// <returns>true if MinimumHours property is set</returns>
        public Boolean IsSetMinimumHours()
        {
            return  this.minimumHoursField != null;

        }


        /// <summary>
        /// Gets and sets the MaximumHours property.
        /// </summary>
        [XmlElementAttribute(ElementName = "MaximumHours")]
        public Decimal MaximumHours
        {
            get { return this.maximumHoursField.GetValueOrDefault() ; }
            set { this.maximumHoursField= value; }
        }



        /// <summary>
        /// Sets the MaximumHours property
        /// </summary>
        /// <param name="maximumHours">MaximumHours property</param>
        /// <returns>this instance</returns>
        public AvailabilityAttributes WithMaximumHours(Decimal maximumHours)
        {
            this.maximumHoursField = maximumHours;
            return this;
        }



        /// <summary>
        /// Checks if MaximumHours property is set
        /// </summary>
        /// <returns>true if MaximumHours property is set</returns>
        public Boolean IsSetMaximumHours()
        {
            return  this.maximumHoursField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetAvailabilityType()) {
                xml.Append("<AvailabilityType>");
                xml.Append(EscapeXML(this.AvailabilityType));
                xml.Append("</AvailabilityType>");
            }
            if (IsSetIsPreorder()) {
                xml.Append("<IsPreorder>");
                xml.Append(this.IsPreorder);
                xml.Append("</IsPreorder>");
            }
            if (IsSetMinimumHours()) {
                xml.Append("<MinimumHours>");
                xml.Append(this.MinimumHours);
                xml.Append("</MinimumHours>");
            }
            if (IsSetMaximumHours()) {
                xml.Append("<MaximumHours>");
                xml.Append(this.MaximumHours);
                xml.Append("</MaximumHours>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}